#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2023/7/11 22:55
# @Author  : sailor233
# @File    : alert.py
# @Software: PyCharm
# @Des     :
from time import sleep

from selenium import webdriver
from selenium.webdriver import ActionChains
from selenium.webdriver.common.by import By

driver = webdriver.Chrome()
driver.implicitly_wait(5)
driver.get('https://www.runoob.com/try/try.php?filename=jqueryui-api-droppable')
# 切换到 iframe框架内
driver.switch_to.frame('iframeResult')
ele_drag = driver.find_element(By.XPATH,'//*[text()="请拖拽我！"]')
ele_drop = driver.find_element(By.XPATH,'//*[text()="请放置到这里！"]')
ActionChains(driver).drag_and_drop(ele_drag,ele_drop).perform()
# 切换到弹窗并点击确认
print(driver.switch_to.alert.text)
driver.switch_to.alert.accept()
sleep(5)